import request from '@/common/request/request.js'
import api from '@/common/api/path.js'

// const request = request.MyRequest()

const reqList = {
	/**
	 * @param {Object} data
	 * 管理员数据统计
	 */
	async getPlatformSummary(data) {
		return await request.MyRequest(api.getPlatformSummary, data, 'GET');
	},
	async queryMsg(data) {
		return await request.MyRequest(api.queryMsg, data, 'POST');
	},
	//公告消息列表
	async queryAllAnnNotice(pageInfo = {
		page: 1,
		size: 10
	}, data = {}) {
		return await request.MyRequest(api.queryAllAnnNotice + `?page=${pageInfo.page}&size=${pageInfo.size}`, data, 'POST');
	},
	//通知消息列表
	async queryAllNotice(pageInfo = {
		page: 1,
		size: 10
	}, data = {}) {
		return await request.MyRequest(api.queryAllNotice + `?page=${pageInfo.page}&size=${pageInfo.size}`, data, 'POST');
	},
	//待办消息列表
	async queryAllNeedNotice(pageInfo = {
		page: 1,
		size: 10
	}, data = {}) {
		return await request.MyRequest(api.queryAllNeedNotice + `?page=${pageInfo.page}&size=${pageInfo.size}`, data,
			'POST');
	},
	async queryNoticeCount(data) {
		var res = await request.MyRequest(api.queryNotice, data, 'POST');
		console.log(res.data.result.count)
		return res.data.result.count
	},
	//showHandleDeal getUnAuditList
	async userProcessInfo(data) {
		return await request.MyRequest(api.userProcessInfo, data, 'POST')
	},
	async slideshow(data) {
		return await request.MyRequest(api.slideshow, data, 'GET')

	},

	async articleContent(data) {
		var ss = await request.MyRequest(api.articleContent, data, 'GET')
		ss.articleImg = ''
		return ss
	},
	async showHandleDeal(pageInfo = {
		page: 1,
		size: 10
	}, data = {
		"procApplyTime": null,
		"processCurrNodeUserId": "",
		"processId": null,
		"processKey": "immigration",
		"processState": "",
		"userId": "",
		"username": null
	}) {
		var data = await request.MyRequest(api.showHandleDeal + `/${pageInfo.page}/${pageInfo.size}`, data, 'POST')
		if (data.data.result != null) {
			data = data.data.result.content
			data.forEach(e => {
				e.procData = JSON.parse(e.procData)
			})
		} else {
			data = []
		}
		return data
	},
	//迁出未审核列表
	async showWaitDeal(pageInfo = {
		page: 1,
		size: 10
	}, data = {
		"procApplyTime": null,
		"processCurrNodeUserId": "",
		"processId": null,
		"processKey": "immigration",
		"processState": "",
		"userId": "",
		"username": null
	}) {
		var data = await request.MyRequest(api.showWaitDeal + `/${pageInfo.page}/${pageInfo.size}`, data, 'POST')
		console.log(data)
		if (data.data.result != null) {
			data = data.data.result.content
			data.forEach(e => {
				e.procData = JSON.parse(e.procData)
			})
		} else {
			data = []
		}
		return data
	},
	async getNoHandleList(pageInfo = {
		page: 1,
		size: 10
	}, data = {
		"processState": "",
		"processCurrNodeUserId": "",
		"userId": "",
		"processKey": "glbt",
		"processId": null,
		"departmentId": null,
		"username": null,
		"procApplyTime": null
	}) {
		var data = await request.MyRequest(api.getNoHandleList + `/${pageInfo.page}/${pageInfo.size}`, data, 'POST')
		if (data.data.result != null) {
			data = data.data.result.content
			data.forEach(e => {
				e.procData = JSON.parse(e.procData)
			})
		} else {
			data = []
		}
		return data
	},
	//已审核表
	async getHandleList(pageInfo = {
		page: 1,
		size: 10
	}, data = {
		processKey: "",
		processState: "",
		processKey: "glbt",
		processCurrNodeUserId: "",
		userId: "",
		processId: null,
		username: null,
		procApplyTime: null
	}) {
		var data = await request.MyRequest(api.getHandleList + `/${pageInfo.page}/${pageInfo.size}`, data, 'POST')
		if (data.data.result != null) {
			data = data.data.result.content
			data.forEach(e => {
				e.procData = JSON.parse(e.procData)
			})
		} else {
			data = []
		}
		return data
	},
	async showLatestApplyUserProcess(data = {
		"processKey": "glbt"
	}) {
		return request.MyRequest(api.showLatestApplyUserProcess, data, 'POST')
	},
	async appProcessProcessInstanceList(pageInfo = {
		page: 1,
		size: 10
	}, data = {
		"departmentId": "",
		"procApplyTime": null,
		"processCurrNodeUserId": "",
		"processId": null,
		"processKey": "glbt",
		"processState": "",
		"userId": "",
		"username": null
	}) {
		return request.MyRequest(api.appProcessProcessInstanceList + `/${pageInfo.page}/${pageInfo.size}`, data, 'POST')
	},
	async getArticleList(data) {
		return request.MyRequest(api.articleList, data, 'GET')
	},
	async appUserApply(data) {
		return request.MyRequest(api.appUserApply, data, 'POST')
	},
	async querySeniorInfo(data) {
		return request.MyRequest(api.querySeniorInfo, data, 'POST')
	},
	async substractInfoWait(data) {
		return request.MyRequest(api.substractInfoWait, data, 'POST')
	},
	async subtractInfoDone(data) {
		return request.MyRequest(api.subtractInfoDone, data, 'GET')
	},
	async subtractInfoWait(data) {
		return request.MyRequest(api.subtractInfoWait, data, 'GET')
	},

	async immigrationCommit(data) {
		return request.MyRequest(api.immigrationCommit, data, 'POST')
	},

	async userImmigrationProcessInfo(data = {
		"processKey": "immigration"
	}) {
		return request.MyRequest(api.userImmigrationProcessInfo, data, 'POST')
	},
	/**
	 * 迁出列表
	 */
	async immigrationList(pageInfo = {
		page: 1,
		size: 10
	}, data = {
		"departmentId": null,
		"procApplyTime": null,
		"processCurrNodeUserId": "",
		"processId": null,
		"processKey": "immigration",
		"processState": "",
		"userId": "",
		"username": null
	}) {
		return request.MyRequest(api.immigrationList + `/${pageInfo.page}/${pageInfo.size}`, data, 'POST')
	},
	/**
	 * @param {Object} data
	 * 待办
	 */
	async queryAllNeedNotice(data) {
		return request.MyRequest(api.queryAllNeedNotice + `?page=${data.page}&size=${data.size}`, {}, 'POST')
	},

	/**
	 * @param {Object} data
	 * 公告
	 */
	async queryAllAnnNotice(data) {
		return request.MyRequest(api.queryAllAnnNotice + `?page=${data.page}&size=${data.size}`, {}, 'POST')
	},

	async queryNotice(data) {
		return request.MyRequest(api.queryNotice + `?page=${data.page}&size=${data.size}`, {}, 'POST')
	},

	async appCommitApplyImmigration(data) {
		return request.MyRequest(api.appCommitApplyImmigration, data, 'POST')
	},

	async getBankTypeByDeptId(data) {
		return request.MyRequest(api.getBankTypeByDeptId, data, 'POST')
	},

	async getDeptTrees(data) {
		return request.MyRequest(api.getDeptTrees, data, 'POST')
	},

	async pushCommit(data) {
		return request.MyRequest(api.pushCommit, data, 'POST')
	},

	async getProcessInstanceList(pageInfo = {
		page: 1,
		size: 10
	}, data = {
		"processKey": "",
		"processState": "",
		"processCurrNodeUserId": "",
		"userId": "",
		"processId": null,
		"departmentId": null,
		"username": null,
		"procApplyTime": null
	}) {
		var data = await request.MyRequest(api.processInstanceList + `/${pageInfo.page}/${pageInfo.size}`, data, 'POST')
		data = data.data.result
		data.forEach(e => {
			e.procData = JSON.parse(e.procData)
		})
		return data
	},

	/**
	 * @param {Object} data
	 * 修改密码
	 */
	async changePass(data) {
		return request.MyRequest(api.changePass, data, 'POST')
	},

	/**
	 * 判断身份证是否合法
	 */
	async validIdCard(data) {
		return request.MyRequest(api.validIdCard, data, 'POST')
	},

	/**
	 * @param {Object} data
	 * 获取开户名 
	 */
	async getName(data) {
		return request.MyRequest(api.queryBankType, data, 'POST')
	},

	/**
	 * @param {Object} data
	 * 获取年份补助情况
	 */
	async getPersonHistory(data) {
		return request.MyRequest(api.queryPersonHistory, data, 'GET')
	},
	async queryBankType() {
		return request.MyRequest(api.queryBankType, {}, 'POST')
	},

	//获取村号
	async Cun(data) {
		return request.MyRequest(api.Cun, data, 'GET')
	},

	async Login(data) {
		return request.MyRequest(api.Login, data, 'POST')
	},

	async getCode(data) {
		console.log(data)
		return request.MyRequest(api.getCode, data, 'POST')
	},

	async register(data) {
		return request.MyRequest(api.register, data, 'POST')
	},

	// 老人查看申请进度
	async UserProcessInfo(data) {
		return request.MyRequest(api.UserProcessInfo, data, 'POST')
	},
	// 高龄津贴申请的图片上传
	async UploadApplicationPic(name, filePath) {
		return request.MyUpload(api.UploadApplicationPic, name, filePath, 'POST')
	},
	// 用户高龄津贴申请
	async AppUserApply(data) {
		data.sbBirth = data.sbIdcard.substr(6, 4) + '-' + data.sbIdcard.substr(10, 2) + '-' + data.sbIdcard.substr(12, 2);
		console.log(data)
		return request.MyRequest(api.AppUserApply, data, 'POST')
	},
	// 老人查看申请记录
	async ProcessInstanceList(url, data) {
		return request.MyRequest(api.ProcessInstanceList + url, data, 'POST')
	},
	async getTown(data) {
		return request.MyRequest(api.getTown, data, 'GET')
	}
}

export default reqList
